﻿namespace RuoVea.ExDto;

/// <summary>
/// 创建人：starry
/// 描 述：分页参数
/// </summary>
public partial class Pagination
{
    /// <summary>
    /// 每页行数
    /// </summary>
    public int PageSize { get; set; }
    /// <summary>
    /// 当前页
    /// </summary>
    public int PageNo { get; set; }
    /// <summary>
    /// 排序列
    /// </summary>
    public string Sidx { get; set; }
    /// <summary>
    /// 排序类型
    /// </summary>
    public string Sord { get; set; } = "asc";
    /// <summary>
    /// 总记录数
    /// </summary>
    public int Total { get; set; }
    /// <summary>
    /// 总页数
    /// </summary>
    public int TotalPage
    {
        get
        {
            if (Total > 0)
            {
                return Total % this.PageSize == 0 ? Total / this.PageSize : Total / this.PageSize + 1;
            }
            else
            {
                return 0;
            }
        }
    }

    /// <summary>
    /// 初始化  默认20行
    /// </summary>
    public Pagination()
    {
        PageNo = 1;
        PageSize = 20;
    }
    /// <summary>
    /// 初始化  默认20行
    /// </summary>
    /// <param name="page">页号</param>
    /// <param name="pageSize">行数</param>
    public Pagination(int page = 1, int pageSize = 20)
    {
        PageNo = page;
        PageSize = pageSize;
    }
    /// <summary>
    /// 初始化 默认20行
    /// </summary>
    /// <param name="pageSize">行数</param>
    public Pagination(int pageSize = 20)
    {
        PageNo = 1;
        PageSize = pageSize;
    }
}
